ARM_LINUX_XXX=/home/xlbtlmy/Desktop/ARM_Linux/gcc-3.4.5-glibc-2.3.6/bin

CC=$(ARM_LINUX_XXX)/arm-linux-gcc
LD=$(ARM_LINUX_XXX)/arm-linux-ld
AR=$(ARM_LINUX_XXX)/arm-linux-ar
OBJCOPY=$(ARM_LINUX_XXX)/arm-linux-objcopy
OBJDUMP=$(ARM_LINUX_XXX)/arm-linux-objdump

INCLUDEDIR	:= $(shell pwd)/include
CFLAGS		:= -Wall -O2
CPPFLAGS	:= -nostdinc -I$(INCLUDEDIR)

export	CC LD AR OBJCOPY OBJDUMP INCLUDEDIR CFLAGS CPPFLAGS

objs := head.o init.o nand.o interrupt.o serial.o lcddrv.o framebuffer.o lcdlib.o main.o lib/libc.a

lcd.bin: $(objs)
	${LD} -Tlcd.lds -o lcd_elf $^
	${OBJCOPY} -O binary -S lcd_elf $@
	${OBJDUMP} -D -m arm lcd_elf > lcd.dis

.PHONY : lib/libc.a
lib/libc.a:
	cd lib; make; cd ..

%.o:%.c
	${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

%.o:%.S
	${CC} $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

clean:
	make  clean -C lib
	rm -f lcd.bin lcd_elf lcd.dis *.o
